CVE-2026-5223: prohibit unpacking symlinks and other unexpected entries
authorJosh Triplett <josh@joshtriplett.org>
Mon, 30 Mar 2026 17:35:55 +0000 (10:35 -0700)
committerFabian Grünbichler <debian@fabian.gruenbichler.email>
Fri, 24 Jul 2026 16:02:33 +0000 (18:02 +0200)
commit858f8ebf80dd3abb8275c72dabcc83d78637490f
treee69c21662856a8f00f3d17a62e7ddbb352aeac5e
parent37ad59f3ec8f7f0764c089aac82663cf383c96de
CVE-2026-5223: prohibit unpacking symlinks and other unexpected entries

Cargo has historically not allowed creating .crate packages containing
symlinks. (It packages the symlink target in place of the symlink,
instead.) So, any package containing a symlink would have to be
hand-constructed. Such packages are also not allowed on crates.io, so it
could only come from an alternate registry.

Rather than dealing with symlink traversal attacks when unpacking a
crate, just prohibit symlinks entirely.

In the process, also prohibit other kinds of unusual entries. As an
exception, allow character devices but warn about them, because some
exist in crates on crates.io.

FG: backported from 1.96.0
Signed-off-by: Fabian Grünbichler <git@fabian.gruenbichler.email>
Gbp-Pq: Topic cargo
Gbp-Pq: Name CVE-2026-5223-prohibit-unpacking-symlinks-and-other-unexp.patch
src/tools/cargo/src/cargo/sources/registry/mod.rs
src/tools/cargo/tests/testsuite/registry.rs